package khs.java_mouse_getpos.main.java;

import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.io.IOException;


/**
 * Hello world!
 *
 */
public class App extends MouseAdapter
{
    public static void main( String[] args ) throws IOException
    {
        
        class InlineThread extends Thread{
            private boolean stop = false;
            
            public void setStop(boolean stop){
                this.stop = stop;
            }
            
            public void run(){
                while(!stop){
                    Point point = MouseInfo.getPointerInfo().getLocation();
                    System.out.println(point);
                    try {
                      Thread.sleep(100);
                  } catch (InterruptedException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
                }
            }
        };
        
        InlineThread inlineThread = new InlineThread();
        inlineThread.start();
        
        System.out.println("press anykey for exit...");
        System.in.read();
        
        inlineThread.setStop(true);
    }
}
